package com.pan.kang.service.impl;

import com.pan.kang.context.IAccComprehensiveQueryContext;
import com.pan.kang.model.vo.*;

import com.pan.kang.service.IAccComprehensiveQueryService;
import com.pan.kang.util.AccConditionUtils;
import com.pan.kang.util.CharConvtUtils;
import com.pan.kang.util.ClassUtil;
import com.pan.kang.util.ConvertUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.*;
import java.util.stream.Collectors;

@Service
@Transactional
public class AccComprehensiveQueryService implements IAccComprehensiveQueryService {

    @Autowired
    private IAccComprehensiveQueryContext accComprehensiveQueryContext;


    public static Map<String, String> cache = new HashMap<>();


    public AccComprehensiveQueryResultVO findList(AccComprehensiveQueryConditionVO conditionVO) {
        List<Map<String, Object>> selectKmWds = new ArrayList();
        this.setConfigParam(conditionVO);
        String beginAccPdId = ConvertUtil.toString(conditionVO.getBeginAccPdId());
        String beginYear = beginAccPdId.substring(0, 4);
        String endAccPdId = ConvertUtil.toString(conditionVO.getEndaccPdId());
        String endYear = endAccPdId.substring(0, 4);
        return (AccComprehensiveQueryResultVO) AccConditionUtils.isAllMatch(new Boolean[]{!beginYear.equals(endYear)})
                .handleConditionWithReturn(() ->
                    this.findListCrossYear(conditionVO)
                , () -> {
                    Map<String, Object> param = new HashMap();
                    Map<String, Object> pageCondition = new HashMap();
                    this.setAllDimList(conditionVO);
                    this.bulidQueryContion(conditionVO, param, pageCondition, selectKmWds);
                    Map<String, Object> queryResultMap = this.accComprehensiveQueryContext.findList(param, pageCondition);
                    AccComprehensiveQueryResultVO resultVO = new AccComprehensiveQueryResultVO();
                    buildQueryResult(resultVO, queryResultMap);
                    return resultVO;
                });
    }


    private AccComprehensiveQueryResultVO findListCrossYear(AccComprehensiveQueryConditionVO accComprehensiveQueryConditionVO) {
        return null;
    }

    private void setConfigParam(AccComprehensiveQueryConditionVO accComprehensiveQueryConditionVO) {
        Map configParams = accComprehensiveQueryConditionVO.getConfigParams();
        configParams.put("QUERY_MAX_RET_COUNT_OJB", 1000);
        configParams.put("FIND_RECORD_LOGS", 1);
        configParams.put("HZ_DATA_LIMIT_QUERY", 1000);
        configParams.put("ACC_GEN_STA_DIM_BAL", 0);
        configParams.put("IS_CUSTOMIZED_BY_GDT", 0);
        configParams.put("IS_SHOW_BEGIN_BALANCE", 1);
        accComprehensiveQueryConditionVO.setConfigParams(configParams);
    }

    public void setAllDimList(AccComprehensiveQueryConditionVO accComprehensiveQueryConditionVO) {
        if (accComprehensiveQueryConditionVO.isShowAllDim()) {
            List<Map> addDimListMap = null;
            if (!CollectionUtils.isEmpty(addDimListMap)) {
                List<AccVouDimDefVO> newAllDimList = addDimListMap.stream().map((e) -> {
                    AccVouDimDefVO accVouDimDefVO = new AccVouDimDefVO();
                    accVouDimDefVO.setDimType((Integer) (e.get("type")));
                    accVouDimDefVO.setDimCap(ConvertUtil.toString(e.get("wdcap")));
                    accVouDimDefVO.setFieNam(ConvertUtil.toString(e.get("name")));
                    accVouDimDefVO.setTypeId(ConvertUtil.toString(e.get("lxid")));
                    return accVouDimDefVO;
                }).collect(Collectors.toList());
                accComprehensiveQueryConditionVO.setAllDimList(newAllDimList);
            }
        }

    }

    public void bulidQueryContion(AccComprehensiveQueryConditionVO accComprehensiveQueryConditionVO, Map<String, Object> param, Map<String, Object> pageCondition, List<Map<String, Object>> selectKmWds) {
        if (accComprehensiveQueryConditionVO != null) {
            Map<String, Object> configParams = accComprehensiveQueryConditionVO.getConfigParams();
            if (Objects.nonNull(configParams)) {
                param.putAll(configParams);
            }

            param.put("recordLogs", accComprehensiveQueryConditionVO.isRecordLogs());
            param.put("selectcompid", accComprehensiveQueryConditionVO.getSelectCompId());
            param.put("selectPftCompId", accComprehensiveQueryConditionVO.getSelectPftCompId());
            if (StringUtils.isNotEmpty(accComprehensiveQueryConditionVO.getSelectPftCompId())) {
                param.put("selectcompid", accComprehensiveQueryConditionVO.getSelectPftCompId());
            }

            param.put("compid", accComprehensiveQueryConditionVO.getCompId());
            param.put("kmLevel", accComprehensiveQueryConditionVO.getSubjectLevel());
            param.put("dateStatus", accComprehensiveQueryConditionVO.getDateStatus());
            param.put("accoStatus", accComprehensiveQueryConditionVO.getAccoStatus());
            param.put("dataType", accComprehensiveQueryConditionVO.getDataType());
            param.put("dataOption", accComprehensiveQueryConditionVO.getDataOption());
            param.put("isShowStopedKm", accComprehensiveQueryConditionVO.getIsShowStopedSubject());
            param.put("isShowAllWd", accComprehensiveQueryConditionVO.isShowAllDim());
            param.put("isShowEmptyDimensionValue", accComprehensiveQueryConditionVO.isShowEmptyDimensionValue());
            param.put("isContainProfitLoss", accComprehensiveQueryConditionVO.getIsContainProfitLoss());
            param.put("isShowDesKmDx", accComprehensiveQueryConditionVO.isShowDesSubjectObject());
            param.put("export", accComprehensiveQueryConditionVO.getExport());
            param.put("isShowHzByStep", false);
            param.put("isShowLj", accComprehensiveQueryConditionVO.isShowCum());
            if (StringUtils.isEmpty(accComprehensiveQueryConditionVO.getMoneyType())) {
                accComprehensiveQueryConditionVO.setMoneyType("0");
            }

            if (accComprehensiveQueryConditionVO.getMoneyType().equals("-2")) {
                param.put("moneyType", "-1");
            } else {
                param.put("moneyType", accComprehensiveQueryConditionVO.getMoneyType());
            }

            param.put("dataStyle", accComprehensiveQueryConditionVO.getDataStyle());
            param.put("baseUnit", accComprehensiveQueryConditionVO.getBaseUnit());
            param.put("accountYear", accComprehensiveQueryConditionVO.getFiscYea());
            param.put("beginAccount", accComprehensiveQueryConditionVO.getBeginAccPdId());
            param.put("endAccount", accComprehensiveQueryConditionVO.getEndaccPdId());
            param.put("accbookid", accComprehensiveQueryConditionVO.getAccBookId());
            param.put("queryModel", accComprehensiveQueryConditionVO.getQueryModel());
            param.put("wdIsEmpty", accComprehensiveQueryConditionVO.isDimIsEmpty());
            param.put("hideCompCol", accComprehensiveQueryConditionVO.isHideCompCol());
            param.put("mergeCol", accComprehensiveQueryConditionVO.getMergeCol());
            param.put("queryFrom", accComprehensiveQueryConditionVO.getQueryFrom());
            String queryModel = accComprehensiveQueryConditionVO.getQueryModel();
            AccPeriodVO beginAccPeriod = accComprehensiveQueryConditionVO.getBeginAccPdCtr();
            Map<String, Object> beginAccountCtr = new HashMap<>();
            if (beginAccPeriod != null) {
                beginAccountCtr.put("accountMonth", beginAccPeriod.getAccMonth());
                beginAccountCtr.put("id", beginAccPeriod.getAccPdId());
                beginAccountCtr.put("ranged", beginAccPeriod.getAdjPerMark());
                beginAccountCtr.put("text", beginAccPeriod.getAccPdName());
            }

            AccPeriodVO endAccPeriod = accComprehensiveQueryConditionVO.getEndaccPdCtr();
            Map<String, Object> endAccountCtr = new HashMap<>();
            if (endAccPeriod != null) {
                endAccountCtr.put("accountMonth", endAccPeriod.getAccMonth());
                endAccountCtr.put("id", endAccPeriod.getAccPdId());
                endAccountCtr.put("ranged", endAccPeriod.getAdjPerMark());
                endAccountCtr.put("text", endAccPeriod.getAccPdName());
            }

            List<AccComprehensiveQuerySelectDimVO> dimValues = accComprehensiveQueryConditionVO.getDimValue();
            List<AccComprehensiveQuerySchemeDimVO> schemeDimValues = accComprehensiveQueryConditionVO.getSchemeDimValue();
            List<AccComprehensiveQuerySelectDimVO> selectDims = accComprehensiveQueryConditionVO.getSelectDim();
            List<AccVouDimDefVO> allDimList = accComprehensiveQueryConditionVO.getAllDimList();
            List<AccComprehensiveQuerySchemeDimVO> schemeSelectDims = accComprehensiveQueryConditionVO.getSchemeSelectDim();
            List<AccComprehensiveQuerySelectDimVO> classifyUseDims = accComprehensiveQueryConditionVO.getClassifyUseDim();
            List<Map<String, Object>> selectWds = new ArrayList<>();
            List<Map<String, Object>> xjmxSelectWds = new ArrayList<>();
            boolean isXjmx = accComprehensiveQueryConditionVO.isSubordinateDetails();
            if (isXjmx) {
                param.put("isShowAllWd", true);
            }

            if (!CollectionUtils.isEmpty(selectDims)) {
                Iterator<AccComprehensiveQuerySelectDimVO> var21 = selectDims.iterator();

                while (var21.hasNext()) {
                    AccComprehensiveQuerySelectDimVO selectDim = (AccComprehensiveQuerySelectDimVO) var21.next();
                    if (StringUtils.equals("{}", selectDim.getSelectValue())) {
                        selectDim.setSelectValue((String) null);
                    }

                    Map<String, Object> selectWd = new HashMap();
                    Map<String, Object> xjmxSelectWd = new HashMap();
                    if (!selectDim.getDimType().equals("2")) {
                        if (isXjmx) {
                            xjmxSelectWd.put("selvalue", selectDim.getSelectValue());
                            xjmxSelectWd.put("tselvalue", selectDim.getSelectDimValue());
                            xjmxSelectWd.put("selwdid", selectDim.getSelectDimId());
                            xjmxSelectWd.put("type", selectDim.getDimType());
                            xjmxSelectWd.put("wdcap", selectDim.getDimCap());
                            xjmxSelectWd.put("wdname", selectDim.getFieNam());
                            xjmxSelectWd.put("lxid", selectDim.getTypeId());
                            xjmxSelectWd.put("attrtype", selectDim.getAttrType());
                            xjmxSelectWd.put("attrvalue", selectDim.getAttrValue());
                            xjmxSelectWds.add(xjmxSelectWd);
                        } else {
                            selectWd.put("selvalue", selectDim.getSelectValue());
                            selectWd.put("tselvalue", selectDim.getSelectDimValue());
                            selectWd.put("selwdid", selectDim.getSelectDimId());
                            selectWd.put("type", selectDim.getDimType());
                            selectWd.put("wdcap", selectDim.getDimCap());
                            selectWd.put("wdname", selectDim.getFieNam());
                            selectWd.put("lxid", selectDim.getTypeId());
                            selectWd.put("attrtype", selectDim.getAttrType());
                            selectWd.put("attrvalue", selectDim.getAttrValue());
                            if ("1".equals(queryModel)) {
                                selectWd.put("groupId", selectDim.getGroupId());
                                selectWd.put("iszdy", selectDim.getIsCustom());
                                selectWd.put("prioritynum", selectDim.getIntfcPrior());
                                selectWd.put("wdcat", selectDim.getDimCat());
                                selectWd.put("wdcollect", selectDim.getDimCollect());
                            }

                            selectWds.add(selectWd);
                        }
                    } else {
                        selectWd.put("selvalue", selectDim.getSelectValue());
                        selectWd.put("tselvalue", selectDim.getSelectDimValue());
                        selectWd.put("selwdid", selectDim.getSelectDimId());
                        selectWd.put("type", selectDim.getDimType());
                        selectWd.put("wdcap", selectDim.getDimCap());
                        selectWd.put("wdname", selectDim.getFieNam());
                        selectWd.put("lxid", selectDim.getTypeId());
                        selectWd.put("attrtype", selectDim.getAttrType());
                        selectWd.put("attrvalue", selectDim.getAttrValue());
                        if ("1".equals(queryModel)) {
                            selectWd.put("groupId", selectDim.getGroupId());
                            selectWd.put("iszdy", selectDim.getIsCustom());
                            selectWd.put("prioritynum", selectDim.getIntfcPrior());
                            selectWd.put("wdcat", selectDim.getDimCat());
                            selectWd.put("wdcollect", selectDim.getDimCollect());
                        }

                        selectWds.add(selectWd);
                    }
                }
            }

            List<Map<String, Object>> wdValues = new ArrayList<>();
            List<Map<String, Object>> schemeSelectWds = new ArrayList<>();
            List<Map<String, Object>> classifyUseWds = new ArrayList<>();
            HashMap schemeSelectWd;
            Iterator var35;
            AccComprehensiveQuerySelectDimVO classifyUseDim;
            HashMap classifyUseWd;
            if ("0".equals(queryModel)) {
                if (!CollectionUtils.isEmpty(dimValues)) {
                    var35 = dimValues.iterator();

                    while (var35.hasNext()) {
                        classifyUseDim = (AccComprehensiveQuerySelectDimVO) var35.next();
                        classifyUseWd = new HashMap();
                        classifyUseWd.put("selvalue", classifyUseDim.getSelectValue());
                        classifyUseWd.put("tselvalue", classifyUseDim.getSelectDimValue());
                        classifyUseWd.put("type", classifyUseDim.getDimType());
                        classifyUseWd.put("wdcap", classifyUseDim.getDimCap());
                        classifyUseWd.put("wdname", classifyUseDim.getFieNam());
                        classifyUseWd.put("lxid", classifyUseDim.getTypeId());
                        wdValues.add(classifyUseWd);
                    }
                }
            } else {
                AccComprehensiveQuerySchemeDimVO schemeSelectDim;
                ArrayList wdDetails;
                List dimDetails;
                Iterator var29;
                AccComprehensiveQuerySelectDimVO dimDetail;
                HashMap wdDetail;
                if (!CollectionUtils.isEmpty(schemeDimValues)) {
                    var35 = schemeDimValues.iterator();

                    while (var35.hasNext()) {
                        schemeSelectDim = (AccComprehensiveQuerySchemeDimVO) var35.next();
                        wdDetails = new ArrayList();
                        schemeSelectWd = new HashMap();
                        dimDetails = schemeSelectDim.getDimDetails();
                        var29 = dimDetails.iterator();

                        while (var29.hasNext()) {
                            dimDetail = (AccComprehensiveQuerySelectDimVO) var29.next();
                            wdDetail = new HashMap();
                            wdDetail.put("groupId", dimDetail.getGroupId());
                            wdDetail.put("iszdy", dimDetail.getIsCustom());
                            wdDetail.put("lxid", dimDetail.getTypeId());
                            wdDetail.put("prioritynum", dimDetail.getIntfcPrior());
                            wdDetail.put("type", dimDetail.getDimType());
                            wdDetail.put("wdcap", dimDetail.getDimCap());
                            wdDetail.put("wdcat", dimDetail.getDimCat());
                            wdDetail.put("wdcollect", dimDetail.getDimCollect());
                            wdDetail.put("wdname", dimDetail.getFieNam());
                            wdDetails.add(wdDetail);
                        }

                        schemeSelectWd.put("queryModel", schemeSelectDim.getQueryModel());
                        schemeSelectWd.put("selvalue", schemeSelectDim.getSelectValue());
                        schemeSelectWd.put("type", schemeSelectDim.getDimType());
                        schemeSelectWd.put("wdclassify", schemeSelectDim.getDimClassify());
                        schemeSelectWd.put("wdtypeStr", schemeSelectDim.getDimTypeName());
                        schemeSelectWd.put("wdDetails", wdDetails);
                        wdValues.add(schemeSelectWd);
                    }
                }

                if (!CollectionUtils.isEmpty(schemeSelectDims)) {
                    var35 = schemeSelectDims.iterator();

                    while (var35.hasNext()) {
                        schemeSelectDim = (AccComprehensiveQuerySchemeDimVO) var35.next();
                        wdDetails = new ArrayList();
                        schemeSelectWd = new HashMap();
                        dimDetails = schemeSelectDim.getDimDetails();
                        var29 = dimDetails.iterator();

                        while (var29.hasNext()) {
                            dimDetail = (AccComprehensiveQuerySelectDimVO) var29.next();
                            wdDetail = new HashMap();
                            wdDetail.put("groupId", dimDetail.getGroupId());
                            wdDetail.put("iszdy", dimDetail.getIsCustom());
                            wdDetail.put("lxid", dimDetail.getTypeId());
                            wdDetail.put("prioritynum", dimDetail.getIntfcPrior());
                            wdDetail.put("type", dimDetail.getDimType());
                            wdDetail.put("wdcap", dimDetail.getDimCap());
                            wdDetail.put("wdcat", dimDetail.getDimCat());
                            wdDetail.put("wdcollect", dimDetail.getDimCollect());
                            wdDetail.put("wdname", dimDetail.getFieNam());
                            wdDetails.add(wdDetail);
                        }

                        schemeSelectWd.put("queryModel", schemeSelectDim.getQueryModel());
                        schemeSelectWd.put("type", schemeSelectDim.getDimType());
                        schemeSelectWd.put("wdclassify", schemeSelectDim.getDimClassify());
                        schemeSelectWd.put("wdtypeStr", schemeSelectDim.getDimTypeName());
                        schemeSelectWd.put("wdDetails", wdDetails);
                        schemeSelectWds.add(schemeSelectWd);
                    }
                }

                if (!CollectionUtils.isEmpty(classifyUseDims)) {
                    var35 = classifyUseDims.iterator();

                    while (var35.hasNext()) {
                        classifyUseDim = (AccComprehensiveQuerySelectDimVO) var35.next();
                        classifyUseWd = new HashMap();
                        classifyUseWd.put("selvalue", classifyUseDim.getSelectValue());
                        classifyUseWd.put("selwdid", classifyUseDim.getSelectDimId());
                        classifyUseWd.put("type", classifyUseDim.getDimType());
                        classifyUseWd.put("wdcap", classifyUseDim.getDimCap());
                        classifyUseWd.put("wdname", classifyUseDim.getFieNam());
                        classifyUseWd.put("lxid", classifyUseDim.getTypeId());
                        classifyUseWd.put("groupId", classifyUseDim.getGroupId());
                        classifyUseWd.put("iszdy", classifyUseDim.getIsCustom());
                        classifyUseWd.put("prioritynum", classifyUseDim.getIntfcPrior());
                        classifyUseWd.put("wdcat", classifyUseDim.getDimCat());
                        classifyUseWd.put("wdcollect", classifyUseDim.getDimCollect());
                    }
                }
            }

            List<Map<String, Object>> allDimDyLists = new ArrayList();
            if (!CollectionUtils.isEmpty(allDimList)) {
                Iterator var38 = allDimList.iterator();

                while (var38.hasNext()) {
                    AccVouDimDefVO accVouDimDef = (AccVouDimDefVO) var38.next();
                    schemeSelectWd = new HashMap();
                    schemeSelectWd.put("type", accVouDimDef.getDimType());
                    schemeSelectWd.put("wdcap", accVouDimDef.getDimCap());
                    schemeSelectWd.put("wdname", accVouDimDef.getFieNam());
                    schemeSelectWd.put("lxid", accVouDimDef.getTypeId());
                    allDimDyLists.add(schemeSelectWd);
                }
            }

            param.put("kmitemcode", accComprehensiveQueryConditionVO.getSubjectItemCode());
            if (!CollectionUtils.isEmpty(selectKmWds)) {
                wdValues.addAll(selectKmWds);
                selectWds.addAll(selectKmWds);
            }

            param.put("wdValue", wdValues);
            param.put("beginAccountCtr", beginAccountCtr);
            param.put("endAccountCtr", endAccountCtr);
            param.put("selectWd", selectWds);
            param.put("xjmxSelectWd", xjmxSelectWds);
            param.put("allDimDyList", allDimDyLists);
            param.put("schemeSelectWd", schemeSelectWds);
            param.put("classifyUseWd", classifyUseWds);
            param.put("kmmc", accComprehensiveQueryConditionVO.getSubjectName());
            param.put("dwmc", accComprehensiveQueryConditionVO.getCompName());
            param.put("kmcode", accComprehensiveQueryConditionVO.getAccoCode());
            param.put("title", accComprehensiveQueryConditionVO.getTitle());
            param.put("iskmdata", accComprehensiveQueryConditionVO.getIsSubjectData());
            param.put("mxdwQuery", accComprehensiveQueryConditionVO.getDtlCompQuert());
            param.put("isCross", accComprehensiveQueryConditionVO.isCross());
            param.put("isKmWdQuery", accComprehensiveQueryConditionVO.getKmWdQuery());
            param.put("xjmx", accComprehensiveQueryConditionVO.isSubordinateDetails());
            param.put("dimAndShowAllDim", accComprehensiveQueryConditionVO.isDimAndShowAllDim());
            param.put("levelDetails", accComprehensiveQueryConditionVO.isLevelDetails());
            param.put("isDirectionColVal", accComprehensiveQueryConditionVO.getDirectionColVal());
            param.put("isShowByUnitTotal", accComprehensiveQueryConditionVO.isShowByUnitTotal());
            if ("2".equals(accComprehensiveQueryConditionVO.getDataStyle())) {
                accComprehensiveQueryConditionVO.setShowBeginBalance(false);
            }

            if ("3".equals(accComprehensiveQueryConditionVO.getAccoStatus())) {
                accComprehensiveQueryConditionVO.setShowBeginBalance(false);
            }

            if (accComprehensiveQueryConditionVO.isShowBeginBalance()) {
                Map<String, Object> beginBalanceParam = new HashMap(param);
                Object account = param.get("accountYear") + "0100";
                beginBalanceParam.put("beginAccount", account);
                beginBalanceParam.put("endAccount", account);
                beginBalanceParam.put("dataType", "BALANCEISNOTZERO");
                param.put("beginBalanceParam", beginBalanceParam);
            }
        }

    }

    public static void buildQueryResult(AccComprehensiveQueryResultVO accComprehensiveQueryResultVO, Map<String, Object> queryResultMap) {
        List<AccComprehensiveQueryListVO> accDimResultList = new ArrayList();
        if (queryResultMap != null) {
            List<Map<String, Object>> queryResults = (List) queryResultMap.get("queryResults");
            String value = "";
            String wdColName = "";
            Iterator var6 = queryResults.iterator();

            label46:
            while (var6.hasNext()) {
                Map<String, Object> queryResult = (Map) var6.next();
                AccComprehensiveQueryListVO accComprehensive = new AccComprehensiveQueryListVO();
                accComprehensive.setAccoLevel(ConvertUtil.toInt(queryResult.get("itemlevel")));
                accComprehensive.setSupeCompId(ConvertUtil.toString(queryResult.get("pcompid")));
                accComprehensive.setCompId(ConvertUtil.toString(queryResult.get("compid")));
                accComprehensive.setCompName(ConvertUtil.toString(queryResult.get("dwmc")));
                accComprehensive.setAccoCode(ConvertUtil.toString(queryResult.get("kmcode")));
                accComprehensive.setSubjectItemCode(ConvertUtil.toString(queryResult.get("kmitemcode")));
                accComprehensive.setSubjectId(ConvertUtil.toInt(queryResult.get("kmid")));
                accComprehensive.setSubjectName(ConvertUtil.toString(queryResult.get("kmmc")));
                accComprehensive.setIsBottLay(ConvertUtil.toInt(queryResult.get("leaf")));
                accComprehensive.setIsSubjectData(ConvertUtil.toInt(queryResult.get("iskmdata")));
                accComprehensive.setIsStoped(ConvertUtil.toInt(queryResult.get("stoped")));
                accComprehensive.setKeyValue(ConvertUtil.toInt(queryResult.get("key_value")));
                accComprehensive.setAccPdId(ConvertUtil.toInt(queryResult.get("account_id")));
                accComprehensive.setAccPdName(ConvertUtil.toString(queryResult.get("zqmc")));
                accComprehensive.setFiscYea(ConvertUtil.toString(queryResult.get("tyear")));
                accComprehensive.setSummary(ConvertUtil.toString(queryResult.get("summary")));
                accComprehensive.setBzxz(ConvertUtil.toString(queryResult.get("bzxz")));
                String qty_type = ConvertUtil.toString(queryResult.get("qty_type"));
                if (StringUtils.isNotEmpty(qty_type)) {
                    accComprehensive.setBzxz(qty_type);
                }

                accComprehensive.setBeginDirection(ConvertUtil.toString(queryResult.get("qcfx")));
                accComprehensive.setFgnBeginRemaining(ConvertUtil.toBigDecimal(queryResult.get("qcye")));
                accComprehensive.setBeginRemaining(ConvertUtil.toBigDecimal(queryResult.get("qcye_bwb")));
                accComprehensive.setFgnDrAmtTot(ConvertUtil.toBigDecimal(queryResult.get("jfje")));
                accComprehensive.setDrAmtTot(ConvertUtil.toBigDecimal(queryResult.get("jfje_bwb")));
                accComprehensive.setFgnCrAmtTot(ConvertUtil.toBigDecimal(queryResult.get("dfje")));
                accComprehensive.setCrAmtTot(ConvertUtil.toBigDecimal(queryResult.get("dfje_bwb")));
                accComprehensive.setEndDirection(ConvertUtil.toString(queryResult.get("qmfx")));
                accComprehensive.setFgnEndRemaining(ConvertUtil.toBigDecimal(queryResult.get("qmye")));
                accComprehensive.setEndRemaining(ConvertUtil.toBigDecimal(queryResult.get("qmye_bwb")));
                accComprehensive.setFgnAnDeAmount(ConvertUtil.toBigDecimal(queryResult.get("jfje_lj")));
                accComprehensive.setAnDeAmount(ConvertUtil.toBigDecimal(queryResult.get("jfje_bwb_lj")));
                accComprehensive.setFgnAnCrAmount(ConvertUtil.toBigDecimal(queryResult.get("dfje_lj")));
                accComprehensive.setAnCrAmount(ConvertUtil.toBigDecimal(queryResult.get("dfje_bwb_lj")));
                accComprehensive.setDrBeginRemaining(ConvertUtil.toBigDecimal(queryResult.get("qcye_bwb_j")));
                accComprehensive.setCrBeginRemaining(ConvertUtil.toBigDecimal(queryResult.get("qcye_bwb_d")));
                accComprehensive.setDrFgnBeginRemaining(ConvertUtil.toBigDecimal(queryResult.get("qcye_j")));
                accComprehensive.setCrFgnBeginRemaining(ConvertUtil.toBigDecimal(queryResult.get("qcye_d")));
                accComprehensive.setDrEndRemaining(ConvertUtil.toBigDecimal(queryResult.get("qmye_bwb_j")));
                accComprehensive.setCrEndRemaining(ConvertUtil.toBigDecimal(queryResult.get("qmye_bwb_d")));
                accComprehensive.setDrFgnEndRemaining(ConvertUtil.toBigDecimal(queryResult.get("qmye_j")));
                accComprehensive.setCrFgnEndRemaining(ConvertUtil.toBigDecimal(queryResult.get("qmye_d")));
                accComprehensive.setDrQcsl(ConvertUtil.toString(queryResult.get("qcsl_j")));
                accComprehensive.setCrQcsl(ConvertUtil.toString(queryResult.get("qcsl_d")));
                accComprehensive.setDrQmsl(ConvertUtil.toString(queryResult.get("qmsl_j")));
                accComprehensive.setCrQmsl(ConvertUtil.toString(queryResult.get("qmsl_d")));
                accComprehensive.setDrQcdj(ConvertUtil.toString(queryResult.get("qcdj_j")));
                accComprehensive.setCrQcdj(ConvertUtil.toString(queryResult.get("qcdj_d")));
                accComprehensive.setDrQmdj(ConvertUtil.toString(queryResult.get("qmdj_j")));
                accComprehensive.setCrQmdj(ConvertUtil.toString(queryResult.get("qmdj_d")));
                accComprehensive.setPftCompId(ConvertUtil.toString(queryResult.get("pftcompid")));
                accComprehensive.setPftCompName(ConvertUtil.toString(queryResult.get("pftcompname")));
                accComprehensive.setMoney2(ConvertUtil.toString(queryResult.get("money2")));
                Iterator var10 = queryResult.keySet().iterator();

                while (true) {
                    String key;
                    do {
                        if (!var10.hasNext()) {
                            accComprehensive.setNumType(ConvertUtil.toString(queryResult.get("numtype")));
                            accComprehensive.setNumScaleType(ConvertUtil.toString(queryResult.get("numscaletype")));
                            accComprehensive.setQcsl(ConvertUtil.toString(queryResult.get("qcye_sl")));
                            accComprehensive.setQcdj(ConvertUtil.toString(queryResult.get("qcye_dj")));
                            accComprehensive.setJfsl(ConvertUtil.toString(queryResult.get("sum_j_sl")));
                            accComprehensive.setJfdj(ConvertUtil.toString(queryResult.get("sum_j_dj")));
                            accComprehensive.setDfsl(ConvertUtil.toString(queryResult.get("sum_d_sl")));
                            accComprehensive.setDfdj(ConvertUtil.toString(queryResult.get("sum_d_dj")));
                            accComprehensive.setQmsl(ConvertUtil.toString(queryResult.get("qmye_sl")));
                            accComprehensive.setQmdj(ConvertUtil.toString(queryResult.get("qmye_dj")));
                            accComprehensive.setLjjfsl(ConvertUtil.toString(queryResult.get("sum_jl_sl")));
                            accComprehensive.setLjjfdj(ConvertUtil.toString(queryResult.get("sum_jl_dj")));
                            accComprehensive.setLjdfsl(ConvertUtil.toString(queryResult.get("sum_dl_sl")));
                            accComprehensive.setLjdfdj(ConvertUtil.toString(queryResult.get("sum_dl_dj")));
                            accComprehensive.setSumjYjz(ConvertUtil.toBigDecimal(queryResult.get("sum_j_yjz")));
                            accComprehensive.setSumjBwbYjz(ConvertUtil.toBigDecimal(queryResult.get("sum_j_bwb_yjz")));
                            accComprehensive.setSumdYjz(ConvertUtil.toBigDecimal(queryResult.get("sum_d_yjz")));
                            accComprehensive.setSumdBwbYjz(ConvertUtil.toBigDecimal(queryResult.get("sum_d_bwb_yjz")));
                            accComprehensive.setSumjlYjz(ConvertUtil.toBigDecimal(queryResult.get("sum_jl_yjz")));
                            accComprehensive.setSumjlBwbYjz(ConvertUtil.toBigDecimal(queryResult.get("sum_jl_bwb_yjz")));
                            accComprehensive.setSumdlYjz(ConvertUtil.toBigDecimal(queryResult.get("sum_dl_yjz")));
                            accComprehensive.setSumdlBwbYjz(ConvertUtil.toBigDecimal(queryResult.get("sum_dl_bwb_yjz")));
                            accComprehensive.setQcyeYjz(ConvertUtil.toString(queryResult.get("qcye_yjz")));
                            accComprehensive.setQcyeBwbYjz(ConvertUtil.toString(queryResult.get("qcye_bwb_yjz")));
                            accComprehensive.setQmyeYjz(ConvertUtil.toString(queryResult.get("qmye_yjz")));
                            accComprehensive.setQmyeBwbYjz(ConvertUtil.toString(queryResult.get("qmye_bwb_yjz")));
                            accComprehensive.setQcyeYjzJ(ConvertUtil.toString(queryResult.get("qcye_yjz_j")));
                            accComprehensive.setQcyeBwbYjzJ(ConvertUtil.toString(queryResult.get("qcye_bwb_yjz_j")));
                            accComprehensive.setQcyeYjzD(ConvertUtil.toString(queryResult.get("qcye_yjz_d")));
                            accComprehensive.setQcyeBwbYjzD(ConvertUtil.toString(queryResult.get("qcye_bwb_yjz_d")));
                            accComprehensive.setQmyeYjzJ(ConvertUtil.toString(queryResult.get("qmye_yjz_j")));
                            accComprehensive.setQmyeBwbYjzJ(ConvertUtil.toString(queryResult.get("qmye_bwb_yjz_j")));
                            accComprehensive.setQmyeYjzD(ConvertUtil.toString(queryResult.get("qmye_yjz_d")));
                            accComprehensive.setQmyeBwbYjzD(ConvertUtil.toString(queryResult.get("qmye_bwb_yjz_d")));
                            accComprehensive.setSumjWjz(ConvertUtil.toBigDecimal(queryResult.get("sum_j_wjz")));
                            accComprehensive.setSumjBwbWjz(ConvertUtil.toBigDecimal(queryResult.get("sum_j_bwb_wjz")));
                            accComprehensive.setSumdWjz(ConvertUtil.toBigDecimal(queryResult.get("sum_d_wjz")));
                            accComprehensive.setSumdBwbWjz(ConvertUtil.toBigDecimal(queryResult.get("sum_d_bwb_wjz")));
                            String subjectAndDimName = ConvertUtil.toString(queryResult.get("subjectAndDimName"));
                            if (StringUtils.isBlank(subjectAndDimName)) {
                                subjectAndDimName = ConvertUtil.toString(queryResult.get("kmmc"));
                            }

                            accComprehensive.setSubjectAndDimName(subjectAndDimName);
                            accComprehensive.setBzRed(ConvertUtil.toString(queryResult.get("bzred")));
                            accDimResultList.add(accComprehensive);
                            accComprehensive.setAnBeginBalanceDirection(ConvertUtil.toString(queryResult.get("qcfx_nc")));
                            accComprehensive.setFgnBeginBalance(ConvertUtil.toBigDecimal(queryResult.get("qcye_nc")));
                            accComprehensive.setFgnJBeginBalance(ConvertUtil.toBigDecimal(queryResult.get("qcye_nc_j")));
                            accComprehensive.setFgnDBeginBalance(ConvertUtil.toBigDecimal(queryResult.get("qcye_nc_d")));
                            accComprehensive.setAnBeginBalance(ConvertUtil.toBigDecimal(queryResult.get("qcye_bwb_nc")));
                            accComprehensive.setAnJBeginBalance(ConvertUtil.toBigDecimal(queryResult.get("qcye_bwb_nc_j")));
                            accComprehensive.setAnDBeginBalance(ConvertUtil.toBigDecimal(queryResult.get("qcye_bwb_nc_d")));
                            continue label46;
                        }

                        key = (String) var10.next();
                    } while (!key.startsWith("dim"));

                    wdColName = CharConvtUtils.lineToHump(key);
                    value = ConvertUtil.toString(queryResult.get(key));

                    try {
                        ClassUtil.setAttribute(accComprehensive, wdColName, value);
                    } catch (RuntimeException var13) {

                    }
                }
            }
        }

        accComprehensiveQueryResultVO.setAccComprehensiveQueryList(accDimResultList);
        accComprehensiveQueryResultVO.setKeyValue(ConvertUtil.toString(queryResultMap.get("keyValue")));
        accComprehensiveQueryResultVO.setDimFieNams(ConvertUtil.toString(queryResultMap.get("dimFieNams")));
    }

}
